package com.book.utils;

import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.IContext;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;

import java.io.Writer;

/**
 * @Author zzw2000
 * @Date 2022年08月10日 18:11
 * @Description 描述
 */
public class ThymeleafUtil {
    private static final TemplateEngine ENGINE;

    static {
        ENGINE = new TemplateEngine();
        ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
        resolver.setCharacterEncoding("UTF-8");
        ENGINE.setTemplateResolver(resolver);
    }

    public static void process(String template, IContext context, Writer writer) {
        ENGINE.process(template, context, writer);
    }
}
